#include "tessitura.h"
#include "ui_tessitura.h"
#include <iostream>
#include <fstream>
#include <QtGui>

using namespace std;

Tessitura::Tessitura(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
    connect(actionPlay, SIGNAL(triggered()), this, SLOT(playSong()));
}

void Tessitura::openFile()
{
        QString path;

        path = QFileDialog::getOpenFileName(
            this,
            "Choose a file to open",
            QString::null,
            QString::null);

          ofstream myfilePC (":/files/songToOpen.txt");
          ofstream myfileMAC ("/Users/CaseyJr/Documents/Programming/QT Projects/Tessitura/TessituraSubversion/Tessitura/songToOpen.txt");
          myfilePC << path.toStdString();
          myfileMAC << path.toStdString();
          myfilePC.close();
          myfileMAC.close();
}

void Tessitura::playSong()
{
    execlp("java", "java", "-jar", "/Users/CaseyJr/Documents/Programming/QT Projects/Tessitura/TessituraSubversion/Tessitura/playmysong.jar", (char*)0);
}
